package cn.com.dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

public class BaseDao {
	public static Configuration configuration=null;
	public static ServiceRegistry serviceRegistry=null;
	public static SessionFactory sessionFactory=null;
	public static Session session=null;
	public static Session getSession(){
		 configuration=new Configuration().configure();
		 serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
		 sessionFactory=configuration.buildSessionFactory(serviceRegistry);
		 session=sessionFactory.openSession();
		return session;
	}
	
}
